**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
** Replication files for Pinto, Rickard and Vreeland (2014) 
** 	The Effect of International Actors on
** 	Public Support for Government Spending Decisions
** Last update: 2024-10-21 by Vreeland
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

clear
set mem 20m
set more off
capture log close

ssc install coefplot
ssc install estout
ssc install mplotoffset
ssc install myaxis

// cd path/to/replication_code.do

log using "replication_log.txt", replace 

** ~~~~~~~~~~~~
** PREPARE DATA FOR ANALYSIS 
** ~~~~~~~~~~~~
use "pinto_rickard_vreeland_2024.dta", clear

** Declare panel structure
xtset numericalid wave


** ~~~~~~~~~~~~
** MAIN RESULTS
** ~~~~~~~~~~~~

** Table 1 ~~~~

* Create a dataset to store summary statistics
tempname tempfile

postfile `tempfile' str20 varname nobs mean_1 mean_2 mean_delta using "table_1.dta", replace

foreach var in all_obs control treat IMFtreat EUtreat {
	
	sum opposecuts if post==0 & `var'==1
		local obs_`var' = r(N)
		local mean_wave1_`var' = r(mean)
		
	sum opposecuts if post==1 & `var'==1
		local mean_wave2_`var' = r(mean)

	sum doppose if `var'==1
		local mean_wavedelta_`var' = r(mean)	
	
	post `tempfile' ("`var'") (`obs_`var'') (`mean_wave1_`var'') (`mean_wave2_`var'') (`mean_wavedelta_`var'')
}

postclose `tempfile'

* Load the dataset and turn it into Latex table
preserve

use "table_1.dta", clear

replace varname = "Full sample" if varname == "all_obs"
replace varname = "Control" if varname == "control"
replace varname = "IMF or EU Treatment" if varname == "treat"
replace varname = "IMF Treatment" if varname == "IMFtreat"
replace varname = "EU Treatment" if varname == "EUtreat"

* Preserve the original row order
gen row = _n
myaxis varname2 = varname, sort(mean row) 
estpost tabstat nobs mean_1 mean_2 mean_delta, by(varname2) nototal 
estimates store table_1

* Export table
esttab table_1 using "Table 1.tex", booktabs replace ///
	cells("varname nobs(fmt(%13.0fc)) mean_1(fmt(2)) mean_2(fmt(2)) mean_delta(fmt(2))") ///
	label ///
    title("Levels of opposition to spending cuts across the two survey waves") ///
    collabels("" "N" "Mean Wave 1" "Mean Wave 2" "Mean $\Delta$") ///
    varlabels(varname " ") ///
	nomtitles ///
	nonumbers ///
    noobs 
	
restore

** Table 2 ~~~~

* Estimate post-only comparisons	
regress opposecuts treat if wave == 2 
matrix t2_treat = r(table)

regress opposecuts IMFtreat if wave == 2 & EUtreat == 0
matrix t2_imf = r(table)

regress opposecuts EUtreat if wave == 2 & IMFtreat == 0
matrix t2_eu = r(table)

* Create a new matrix to store all the results
matrix table2 = (t2_treat[1,1], t2_treat[2,1], t2_treat[5,1], t2_treat[6,1], t2_treat[3,1], t2_treat[4,1]) \ ///
               (t2_imf[1,1], t2_imf[2,1], t2_imf[5,1], t2_imf[6,1], t2_imf[3,1], t2_imf[4,1]) \ ///
               (t2_eu[1,1], t2_eu[2,1], t2_eu[5,1], t2_eu[6,1], t2_eu[3,1], t2_eu[4,1])

matrix rownames table2 = "Treatment - Control" "IMF - Control" "EU - Control"

* Export table
esttab matrix(table2, fmt(2)) using "Table 2.tex", booktabs replace ///
	title("Post-only (Wave 2) comparisons") ///
    collabels("Mean" "Std Error" "[95\%" "Conf. Int.]" "\textit{t}" "\textit{p}" ) ///
	nomtitles
    
** Table 3 ~~~~~

* Estimate diff-in-diff comparisons
regress opposecuts treat##wave, cluster(numericalid)
matrix t3_treat = r(table)

regress opposecuts IMFtreat##wave if EUtreat == 0, cluster(numericalid)
matrix t3_imf = r(table)

regress opposecuts EUtreat##wave if IMFtreat == 0, cluster(numericalid)
matrix t3_eu = r(table)

* Create a new matrix to store all the results
matrix table3 = (t3_treat[1,8], t3_treat[2,8], t3_treat[5,8], t3_treat[6,8], t3_treat[3,8], t3_treat[4,8]) \ ///
               (t3_imf[1,8], t3_imf[2,8], t3_imf[5,8], t3_imf[6,8], t3_imf[3,8], t3_imf[4,8]) \ ///
               (t3_eu[1,8], t3_eu[2,8], t3_eu[5,8], t3_eu[6,8], t3_eu[3,8], t3_eu[4,8])

* Set column names for statistics and row names for models
matrix rownames table3 = "Treatment - Control" "IMF - Control" "EU - Control"

* Export table
esttab matrix(table3, fmt(2)) using "Table 3.tex", booktabs replace ///
	title("Pre-post analysis (difference in differences)") ///
    collabels("Mean" "Std Error" "[95\%" "Conf. Int.]" "\textit{t}" "\textit{p}" ) ///
	nomtitles

** ~~~~~~~~~~~~
** SPECIFIC BUDGET CUTS
** ~~~~~~~~~~~~
	
** Figure 1 ~~~~~

* Estimate models
xtreg opposecuts treat##post, cluster(numericalid) fe
estimates store Treatment

xtreg opposecuts IMFtreat##post if EUtreat != 1, cluster(numericalid) fe
estimates store IMF

xtreg opposecuts EUtreat##post if IMFtreat != 1, cluster(numericalid) fe
estimates store EU

* Export plot
coefplot (Treatment, ///
			offset(0) ///
			mcol(dkgreen) ///
			ciopts(lcolor(dkgreen)) ///
			mlabcolor(dkgreen)) ///
		 (IMF, ///
			offset(0) ///
			mcol(maroon) ///
			ciopts(lcolor(maroon)) ///
			mlabcolor(maroon)) ///
		 (EU, ///
			offset(0) ///
			mcol(dknavy) ///
			ciopts(lcolor(dknavy)) ///
			mlabcolor(dknavy)), ///
		 coeflabels(1.treat#1.post="EU or IMF" ///
            1.IMFtreat#1.post="IMF" ///
            1.EUtreat#1.post="EU", notick) ///
			keep(1.treat#1.post 1.IMFtreat#1.post 1.EUtreat#1.post) ///
			xline(0, lcolor(black) lwidth(thin) lpattern(dash)) ///
			ciopts(recast(rspike)) ///
		graphregion(fcolor(white) lcolor(white)) ///
		format(%9.2f) ///
		mlabel ///
		mlabposition(12) ///
		mlabgap(*2) ///
		legend(pos(6) order(7 "Difference in Δ Oppose Cuts") ///
        region(lstyle(none))) ///
		ylabel(1 "(EU or IMF) - Control" ///
           2 "IMF - Control" ///
           3 "EU - Control")

graph export "Figure 1.png", as(png) width(1200) height(600) replace

** Figure 2 ~~~~~

* Estimate models
xtreg opposecuts IMFtreat##EUtreat##post if smallcut==1, cluster(numericalid) fe
estimates store Small

xtreg opposecuts IMFtreat##EUtreat##post if smallcut==0, cluster(numericalid) fe
estimates store Large

* Export plot
coefplot (Small, ///
			offset(-0.20) ///
			mcol(dknavy) ///
			ciopts(lcolor(dknavy)) ///
			mlabcolor(dknavy)) ///
		 (Large, ///
			offset(0.20) ///
			mcol(maroon) ///
			ciopts(lcolor(maroon)) ///
			mlabcolor(maroon)), ///
		coeflabels(1.post="Control"  1.IMFtreat#1.post="IMF Treatment" 1.EUtreat#1.post="EU Treatment", notick) ///
		keep(1.post 1.IMFtreat#1.post 1.EUtreat#1.post) ///
		xline(0, lcolor(black) lwidth(thin) lpattern(dash)) ciopts(recast(rspike)) graphregion(fcolor(white) lcolor(white)) ///
		format(%9.2f) ///
		mlabel ///
		mlabposition(12) ///
		mlabgap(*2) ///
		legend(pos(6) rows(1) order(2 "Small Cuts" 4 "Large Cuts") region(lstyle(none)))
		
graph export "Figure 2.png", as(png) width(1200) height(600) replace

** Figure 3 ~~~~~

* Estimate models
xtreg opposecuts IMFtreat##EUtreat##post if all_education==0, cluster(numericalid) fe
estimates store EU_Not 

xtreg opposecuts IMFtreat##EUtreat##post if all_education==1, cluster(numericalid) fe
estimates store EU_Education 
 
* Export plot
coefplot (EU_Not, ///
			offset(0.20) ///
			mcol(dknavy) ///
			ciopts(lcolor(dknavy)) ///
			mlabcolor(dknavy)) ///
		 (EU_Education, ///
			offset(-0.20) ///
			mcol(maroon) ///
			ciopts(lcolor(maroon)) ///
			mlabcolor(maroon)), ///	 
		 coeflabels(1.post="Control"  1.IMFtreat#1.post="IMF Treatment" 1.EUtreat#1.post="EU Treatment", notick) ///
		keep(1.post 1.IMFtreat#1.post 1.EUtreat#1.post) ///
		 xline(0, lcolor(black) lwidth(thin) lpattern(dash)) ciopts(recast(rspike)) ///
		 graphregion(fcolor(white) lcolor(white)) ///
		 format(%9.2f) ///
		 mlabel ///
		 mlabposition(12) ///
		 mlabgap(*2) ///
		 legend(pos(6) rows(1) order(2 "Education Cuts not Mentioned" 4 "Education Cuts Explicitly Mentioned") region(lstyle(none))) 
		 
graph export "Figure 3.png", as(png) width(1200) height(600) replace


** ~~~~~~~~~~~~
** POLITICAL ORIENTATION
** ~~~~~~~~~~~~

** Figure 4 ~~~~~

* Estimate models
xtreg opposecuts group##post##support_gov, cluster(numericalid) fe
margins r.group, at(post=(1) support_gov=(0)) noestimcheck post
estimates store margins_opposition

xtreg opposecuts group##post##support_gov, cluster(numericalid) fe
margins r.group, at(post=(1) support_gov=(1)) noestimcheck post
estimates store margins_government

* Export plot
coefplot (margins_government, ///
			offset(0.20) ///
			mcol(dknavy) ///
			ciopts(lcolor(dknavy)) ///
			mlabcolor(dknavy)) ///
		 (margins_opposition, ///
			msymbol(T) ///
			offset(-0.20) ///
			mcol(maroon) ///
			ciopts(lcolor(maroon)) ///
			mlabcolor(maroon)), ///
		 xline(0, lcolor(black) lwidth(thin) lpattern(dash)) ///
		 ciopts(recast(rspike)) ///
		 graphregion(fcolor(white) lcolor(white)) ///
		 format(%9.2f) ///
		 mlabel ///
		 mlabposition(12) ///
		 mlabgap(*2) ///
		 legend(pos(6) rows(1) order(2 "Supports Government" 4 "Opposes Government") region(lstyle(none))) ///
		 ylabel(1 "IMF Treatment–Control" 2 "EU Treatment–Control", notick) ///
		 xlabel(-1 (.5) .5,format(%9.1f))		 
	 
graph export "Figure 4.png", as(png) width(1200) height(600) replace

** ~~~~~~~~~~~~
** NATIONALISM
** ~~~~~~~~~~~~

** Figure 5 ~~~~~

* Estimate models
xtreg opposecuts group##post##nationalist, cluster(numericalid) fe
margins r.group, at(post=(1) nationalist=(0)) noestimcheck post
estimates store margins_nonnationalist

xtreg opposecuts group##post##nationalist, cluster(numericalid) fe
margins r.group, at(post=(1) nationalist=(1)) noestimcheck post
estimates store margins_nationalist

* Export plot
coefplot (margins_nonnationalist, ///
			offset(0.20) ///
			mcol(dknavy) ///
			ciopts(lcolor(dknavy)) ///
			mlabcolor(dknavy)) ///
		 (margins_nationalist, ///
			msymbol(T) ///
			offset(-0.20) ///
			mcol(maroon) ///
			ciopts(lcolor(maroon)) ///
			mlabcolor(maroon)), ///
		 xline(0, lcolor(black) lwidth(thin) lpattern(dash)) ///
		 ciopts(recast(rspike)) ///
		 graphregion(fcolor(white) lcolor(white)) ///
		 format(%9.2f) ///
		 mlabel ///
		 mlabposition(12) ///
		 mlabgap(*2) ///
		 legend(pos(6) rows(1) order(2 "Non-nationalist" 4 "Nationalist") region(lstyle(none))) ///
		 ylabel(1 "IMF Treatment–Control" 2 "EU Treatment–Control", notick) ///
		 xlabel(-1 (.5) .5,format(%9.1f))	

graph export "Figure 5.png", as(png) width(1200) height(600) replace

** ~~~~~~~~~~~~
** APPENDIX
** ~~~~~~~~~~~~

** Table A1 ~~~~~

* Create a dataset to store summary statistics
tempname tempfile

postfile `tempfile' str20 varname eu imf eu_imf smallcut edu health using "table_a1.dta", replace

foreach demo_var in age income gender support_gov education {
	foreach group_var in EUtreat IMFtreat treat smallcut all_education not_health {
		disp "Compare " "`demo_var'" " across " "`group_var'"
		ttest `demo_var' if post==0, by(`group_var')
		local p_`demo_var'_`group_var' = r(p)
	}
		
	post `tempfile' ("`demo_var'") (`p_`demo_var'_EUtreat') (`p_`demo_var'_IMFtreat') (`p_`demo_var'_treat') (`p_`demo_var'_smallcut') (`p_`demo_var'_all_education') (`p_`demo_var'_not_health')
}

postclose `tempfile'

* Load the dataset and turn it into Latex table
preserve 
use "table_a1.dta", clear

replace varname = "Age (continuous)" if varname == "age"
replace varname = "Income (continuous)" if varname == "income"
replace varname = "Gender" if varname == "gender"
replace varname = "Support for Government" if varname == "support_gov"
replace varname = "Education (continuous)" if varname == "education"

* Preserve the original row order
gen row = _n
myaxis varname2 = varname, sort(mean row) 
estpost tabstat eu imf eu_imf smallcut edu health, by(varname2) nototal 
estimates store table_a1

* Export table
esttab table_a1 using "Table A1.tex", booktabs replace ///
	cells("varname eu(fmt(2)) imf(fmt(2)) eu_imf(fmt(2)) smallcut(fmt(2)) edu(fmt(2)) health(fmt(2))") ///
	label ///
    title("Balance of salient socioeconomic characteristics within sample subgroups") ///
    collabels("" "EU" "IMF" "EU-IMF" "Small Cuts" "Including Education" "Maintain Health") ///
    varlabels(varname " ") ///
	nomtitles ///
	nonumbers ///
    noobs ///
	addnotes("Clustered standard errors in parentheses" "* p$<$.1 ** p$<$.05 *** P$<$.01")
	
restore

** Table A2 ~~~~~

* Estimate model
reg doppose i.group i.income i.party i.education age , robust
estimates store model_a2

* Export table
esttab model_a2 using "Table A2.tex", booktabs replace ///
		r2(3) b(3) se(3) ///
		title("Change in opposition to spending cuts (regression analysis, with controls)") ///
		label ///
		stats(N r2, fmt(0 3) labels("N" "R-squared")) ///
		star(* 0.1 ** 0.05 *** 0.01) ///
		drop(1.income 0.party 1.education 0.group) ///
		refcat(1.group "{\textit{Foreign influence}}" 2.income "{\textit{Income}}" 1.party "{\textit{Party}}" 2.education "{\textit{Education}}", nolabel) ///
		cells("b(fmt(3) star) se(fmt(3) par)") collabels("Coefficient" "Std. error" , lhs(`:var lab `e(depvar)'')) ///
		eqlabel(none) ///
		mtitles( "DV: $\Delta$ Oppose Cuts") ///
		nonumbers ///
		nonotes ///
		addnotes("Robust standard errors in parentheses" "* p$<$.1 ** p$<$.05 *** P$<$.01")
	
** Figure A1 ~~~~~

* Estimate model
xi: xtreg opposecuts group##post##c.no_foreign_intervention, cl( numericalid ) fe
margins r.group, at(post=(1) no_foreign=(-.269 0 .262 .532 .793)) noestimcheck post
estimates store margins_factor

* Export table
mplotoffset, ///
	ciopts(recast(rspike))  ///
	recast(scatter)  ///
	graphregion(fcolor(white) lcolor(white)) ///
	legend(pos(6) rows(1) order(3 "ΔIMF Treatment" 4 "ΔEU Treatment") ///
	region(lstyle(none))) ///
	xlabel(-.262 "-.26" 0  .262 ".26" .532 ".53" .793 ".79") ///
	title("") ///
	ytitle("Difference with ΔControl") ///
	yline(0, lcolor(black) lwidth(thin) lpattern(dash)) ///
	xtitle("Factor Score: Oppose foreign intervention") 

graph export "Figure A1.png", as(png) width(1200) height(600) replace
		
** Table A3 ~~~~~

* Estimate model
xtreg opposecuts EUtreat##post##smallcut IMFtreat##post##smallcut, cluster(numericalid) fe
estimates store model_a3
estadd local unitfe "Yes"

* Export table
esttab model_a3 using "Table A3.tex", replace booktabs ///
		r2(3) b(3) se(3)  ///
		keep(1.post 1.IMFtreat#1.post 1.EUtreat#1.post 1.post#1.smallcut 1.IMFtreat#1.post#1.smallcut 1.EUtreat#1.post#1.smallcut _cons) 	///
		order(1.post 1.IMFtreat#1.post 1.EUtreat#1.post 1.post#1.smallcut 1.IMFtreat#1.post#1.smallcut 1.EUtreat#1.post#1.smallcut) ///
		coeflabels(1.post "Post" 1.IMFtreat#1.post "Post x IMF" 1.EUtreat#1.post "Post x EU" 1.post#1.smallcut "Post x Small Cut" 1.IMFtreat#1.post#1.smallcut "Post x IMF x Small Cut" 1.EUtreat#1.post#1.smallcut "Post x EU x Small Cut" _cons "Constant") ///
		title("Opposition to spending cuts, by size of spending cuts") ///
		mtitles("DV: Oppose Spending Cuts") ///
		stats(N N_g r2 unitfe, fmt(0 0 3 %9.0fc) labels("N" "Units" "R-squared" "Unit fixed effects")) ///
		star(* 0.1 ** 0.05 *** 0.01) ///
		nonumbers ///
		nonotes ///
		addnotes("Clustered standard errors in parentheses" "* p$<$.1 ** p$<$.05 *** P$<$.01")

		
** Table A4 ~~~~~

* Estimate models
xtreg opposecuts EUtreat##post IMFtreat##post if smallcut==1 , cluster(numericalid) fe
estimates store model_a4_1
xtreg opposecuts EUtreat##post IMFtreat##post if smallcut==0 , cluster(numericalid) fe
estimates store model_a4_2

* Export table
esttab model_a4_1 model_a4_2 using "Table A4.tex", replace booktabs /// ///
		b(3) se(3)  ///
		keep(1.post 1.IMFtreat#1.post 1.EUtreat#1.post) ///
		order(1.post 1.IMFtreat#1.post 1.EUtreat#1.post) ///
		coeflabels(1.post "$\Delta$ Control (Pre-Post)" 1.IMFtreat#1.post "$\Delta$ IMF - $\Delta$ Control" 1.EUtreat#1.post "$\Delta$ European Union - $\Delta$ Control") ///
		title("Average treatment effects, by size of spending cuts") ///
		mtitles("Small Cuts" "Large Cuts") ///
		star(* 0.1 ** 0.05 *** 0.01) ///
		noobs ///
		nonumbers ///
		nonotes ///
		addnotes("Clustered standard errors in parentheses" "* p$<$.1 ** p$<$.05 *** P$<$.01")
		
** Table A5 ~~~~~

* Estimate model
xtreg opposecuts EUtreat##post##all_education IMFtreat##post##all_education, cluster(numericalid) fe
estimates store model_a5
estadd local unitfe "Yes"

* Export table
esttab model_a5 using "Table A5.tex", replace booktabs ///
		r2(3) b(3) se(3)  ///
		keep(1.post 1.IMFtreat#1.post 1.EUtreat#1.post 1.post#1.all_education 1.IMFtreat#1.post#1.all_education 1.EUtreat#1.post#1.all_education _cons) 	///
		order(1.post 1.IMFtreat#1.post 1.EUtreat#1.post 1.post#1.all_education 1.IMFtreat#1.post#1.all_education 1.EUtreat#1.post#1.all_education) ///
		coeflabels(1.post "Post" 1.IMFtreat#1.post "Post x IMF" 1.EUtreat#1.post "Post x EU" 1.post#1.all_education "Post x Education Cuts" 1.IMFtreat#1.post#1.all_education "Post x IMF x Education Cuts" 1.EUtreat#1.post#1.all_education "Post x EU x Education Cuts" _cons "Constant") ///
		title("Opposition to spending cuts, by type of spending cuts (include education)") ///
		mtitles("DV: Oppose Spending Cuts") ///
		stats(N N_g r2 unitfe, fmt(0 0 3 %9.0fc) labels("N" "Units" "R-squared" "Unit fixed effects")) ///
		star(* 0.1 ** 0.05 *** 0.01) ///
		nonumbers ///
		nonotes ///
		addnotes("Clustered standard errors in parentheses" "* p$<$.1 ** p$<$.05 *** P$<$.01")
		
** Table A6 ~~~~~

* Estimate models
xtreg opposecuts EUtreat##post IMFtreat##post if all_education==1 , cluster(numericalid) fe
estimates store model_a6_1
xtreg opposecuts EUtreat##post IMFtreat##post if all_education==0 , cluster(numericalid) fe
estimates store model_a6_2

* Export table
esttab model_a6_1 model_a6_2 using "Table A6.tex", replace booktabs ///
		b(3) se(3)  ///
		keep(1.post 1.IMFtreat#1.post 1.EUtreat#1.post) ///
		order(1.post 1.IMFtreat#1.post 1.EUtreat#1.post) ///
		coeflabels(1.post "$\Delta$ Control (Pre-Post)" 1.IMFtreat#1.post "$\Delta$ IMF - $\Delta$ Control" 1.EUtreat#1.post "$\Delta$ European Union - $\Delta$ Control") ///
		title("Average treatment effects, by type of spending cuts (include education)") ///
		mtitles("Education Cuts Included" "Education not Mentioned") ///
		star(* 0.1 ** 0.05 *** 0.01) ///
		noobs ///
		nonumbers ///
		nonotes ///
		addnotes("Clustered standard errors in parentheses" "* p$<$.1 ** p$<$.05 *** P$<$.01")

** Table A7 ~~~~~

* Estimate model
xtreg opposecuts EUtreat##post##not_health IMFtreat##post##not_health, cluster(numericalid) fe
estimates store model_a7
estadd local unitfe "Yes"

* Export table
esttab model_a7 using "Table A7.tex", replace booktabs ///
		r2(3) b(3) se(3)  ///
		keep(1.post 1.IMFtreat#1.post 1.EUtreat#1.post 1.post#1.not_health 1.IMFtreat#1.post#1.not_health 1.EUtreat#1.post#1.not_health _cons) 	///
		order(1.post 1.IMFtreat#1.post 1.EUtreat#1.post 1.post#1.not_health 1.IMFtreat#1.post#1.not_health 1.EUtreat#1.post#1.not_health) ///
		coeflabels(1.post "Post" 1.IMFtreat#1.post "Post x IMF" 1.EUtreat#1.post "Post x EU" 1.post#1.not_health "Post x Keep Health" 1.IMFtreat#1.post#1.not_health "Post x IMF x Keep Health" 1.EUtreat#1.post#1.not_health "Post x EU x Keep Health" _cons "Constant") ///
		title("Opposition to spending cuts, by type of spending cuts (maintain health)") ///
		mtitles("DV: Oppose Spending Cuts") ///
		stats(N N_g r2 unitfe, fmt(0 0 3 %9.0fc) labels("N" "Units" "R-squared" "Unit fixed effects")) ///
		star(* 0.1 ** 0.05 *** 0.01) ///
		nonumbers ///
		nonotes ///
		addnotes("Clustered standard errors in parentheses" "* p$<$.1 ** p$<$.05 *** P$<$.01")

** Table A8 ~~~~~

* Estimate models
xtreg opposecuts EUtreat##post IMFtreat##post if not_health==1 , cluster(numericalid) fe
estimates store model_a8_1
xtreg opposecuts EUtreat##post IMFtreat##post if not_health==0 , cluster(numericalid) fe
estimates store model_a8_2

* Export table
esttab model_a8_1 model_a8_2 using "Table A8.tex", replace booktabs ///
		b(3) se(3)  ///
		keep(1.post 1.IMFtreat#1.post 1.EUtreat#1.post) ///
		order(1.post 1.IMFtreat#1.post 1.EUtreat#1.post) ///
		coeflabels(1.post "$\Delta$ Control (Pre-Post)" 1.IMFtreat#1.post "$\Delta$ IMF - $\Delta$ Control" 1.EUtreat#1.post "$\Delta$ European Union - $\Delta$ Control") ///
		title("Average treatment effects, by type of spending cuts (maintain health)") ///
		mtitles("Health Spending Maintained" "Health Spending not Mentioned") ///
		star(* 0.1 ** 0.05 *** 0.01) ///
		noobs ///
		nonumbers ///
		nonotes ///
		addnotes("Clustered standard errors in parentheses" "* p$<$.1 ** p$<$.05 *** P$<$.01")

** Table A9 ~~~~~

* Estimate models
xtreg opposecuts EUtreat##post##support_gov IMFtreat##post##support_gov, cluster(numericalid) fe
estimates store model_a9
estadd local unitfe "Yes"

* Export table
esttab model_a9 using "Table A9.tex",  replace booktabs ///
		r2(3) b(3) se(3)  ///
		keep(1.post 1.IMFtreat#1.post 1.EUtreat#1.post 1.post#1.support_gov 1.IMFtreat#1.post#1.support_gov 1.EUtreat#1.post#1.support_gov _cons) 	///
		order(1.post 1.IMFtreat#1.post 1.EUtreat#1.post 1.post#1.support_gov 1.IMFtreat#1.post#1.support_gov 1.EUtreat#1.post#1.support_gov) ///
		coeflabels(1.post "Post" 1.IMFtreat#1.post "Post x IMF" 1.EUtreat#1.post "Post x EU" 1.post#1.support_gov "Post x Pro-government" 1.IMFtreat#1.post#1.support_gov "Post x IMF x Pro-government" 1.EUtreat#1.post#1.support_gov "Post x EU x Pro-government" _cons "Constant") ///
		title("Opposition to spending cuts, by support for government") ///
		mtitles("DV: Oppose Spending Cuts") ///
		stats(N N_g r2 unitfe, fmt(0 0 3 %9.0fc) labels("N" "Units" "R-squared" "Unit fixed effects")) ///
		star(* 0.1 ** 0.05 *** 0.01) ///
		nonumbers ///
		nonotes ///
		addnotes("Clustered standard errors in parentheses" "* p$<$.1 ** p$<$.05 *** P$<$.01")

** Table A10 ~~~~~

* Estimate models
xtreg opposecuts EUtreat##post IMFtreat##post if support_gov==1 , cluster(numericalid) fe
estimates store model_a10_1
xtreg opposecuts EUtreat##post IMFtreat##post if support_gov==0 , cluster(numericalid) fe
estimates store model_a10_2

* Export table
esttab model_a10_1 model_a10_2 using "Table A10.tex", replace booktabs ///
		b(3) se(3)  ///
		keep(1.post 1.IMFtreat#1.post 1.EUtreat#1.post) ///
		order(1.post 1.IMFtreat#1.post 1.EUtreat#1.post) ///
		coeflabels(1.post "$\Delta$ Control (Pre-Post)" 1.IMFtreat#1.post "$\Delta$ IMF - $\Delta$ Control" 1.EUtreat#1.post "$\Delta$ European Union - $\Delta$ Control") ///
		title("Average treatment effects, by support for government") ///
		mtitles("Supports Government" "Opposes Government") ///
		star(* 0.1 ** 0.05 *** 0.01) ///
		noobs ///
		nonumbers ///
		nonotes ///
		addnotes("Clustered standard errors in parentheses" "* p$<$.1 ** p$<$.05 *** P$<$.01")

** Table A11 ~~~~~

* Generate a variable for use only in these regressions
gen a11 = nationalist

* Estimate models
xtreg opposecuts EUtreat##post##c.a11 IMFtreat##post##c.a11, cluster(numericalid) fe
estimates store model_a11_1
estadd local unitfe "Yes"

replace a11 = no_foreign_intervention
xtreg opposecuts EUtreat##post##c.a11 IMFtreat##post##c.a11, cluster(numericalid) fe
estimates store model_a11_2
estadd local unitfe "Yes"

* Export table
esttab model_a11_1 model_a11_2 using "Table A11.tex", replace booktabs /// ///
		r2(3) b(3) se(3)  ///
		keep(1.post 1.IMFtreat#1.post 1.EUtreat#1.post 1.post#c.a11 1.IMFtreat#1.post#c.a11 1.EUtreat#1.post#c.a11 _cons) ///
		order(1.post 1.IMFtreat#1.post 1.EUtreat#1.post 1.post#c.a11 1.IMFtreat#1.post#c.a11 1.EUtreat#1.post#c.a11) ///
		coeflabels(1.post "Post" 1.IMFtreat#1.post "Post x IMF" 1.EUtreat#1.post "Post x EU" 1.post#c.a11 "Post x Oppose Foreign Intervention" 1.IMFtreat#1.post#c.a11 "Post x IMF x Oppose Foreign Intervention" 1.EUtreat#1.post#c.a11 "Post x EU x Oppose Foreign Intervention" _cons "Constant") ///
		title("Opposition to spending cuts, by opposition to foreign intervention") ///
		mtitles("1-item measure" "Factor score") ///
		stats(N N_g r2 unitfe, fmt(0 0 3 %9.0fc) labels("N" "Units" "R-squared" "Unit fixed effects")) ///
		star(* 0.1 ** 0.05 *** 0.01) ///
		nodepvars ///
		nonotes ///
		addnotes("Clustered standard errors in parentheses" "* p$<$.1 ** p$<$.05 *** P$<$.01")

** Table A12 ~~~~~

* Estimate models
xtreg opposecuts EUtreat##post IMFtreat##post if nationalist==1 , cluster(numericalid) fe
estimates store model_a12_1
xtreg opposecuts EUtreat##post IMFtreat##post if nationalist==0 , cluster(numericalid) fe
estimates store model_a12_2

* Export table
esttab model_a12_1 model_a12_2 using "Table A12.tex", replace booktabs ///
		b(3) se(3)  ///
		keep(1.post 1.IMFtreat#1.post 1.EUtreat#1.post) ///
		order(1.post 1.IMFtreat#1.post 1.EUtreat#1.post) ///
		coeflabels(1.post "$\Delta$ Control (Pre-Post)" 1.IMFtreat#1.post "$\Delta$ IMF - $\Delta$ Control" 1.EUtreat#1.post "$\Delta$ European Union - $\Delta$ Control") ///
		title("Average treatment effects, by opposition to foreign intervention") ///
		mtitles("Opposes" "Does not oppose") ///
		star(* 0.1 ** 0.05 *** 0.01) ///
		noobs ///
		nonumbers ///
		nonotes ///
		addnotes("Clustered standard errors in parentheses" "* p$<$.1 ** p$<$.05 *** P$<$.01")
		
** ~~~~~~~~~~~~
** END
** ~~~~~~~~~~~~

disp "Script completed"
log off